using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace ThoiTrang.Data
{
    public static class General
    {
        private static string connectionString = "server=221.121.12.132;database=thoitrang;uid=thoitrang;pwd=duc321;";
        private static SqlConnection connection = new SqlConnection(connectionString);
        private static SqlCommand command;        

        public static void MappingCatMainToXml(string path)
        {
            command = new SqlCommand("GetCatMainList", connection);
            command.CommandType = CommandType.StoredProcedure;
            command.Connection.Open();
            DataSet dataset = new DataSet("CatMains");
            dataset.Load(command.ExecuteReader(), LoadOption.OverwriteChanges, "CatMain");
            dataset.WriteXml(path);
            command.Connection.Close();
        }   
     
        /// <summary>
        /// HungNC 03032009 ham su dung de chay cau lenh sql
        /// </summary>
        /// <param name="sqlstatement"></param>
        /// <returns></returns>
        public static DataTable ExecSQLStatement(string sqlstatement)
        {
            Database database = DatabaseFactory.CreateDatabase();
            DataSet ds = new DataSet() ;
            ds = database.ExecuteDataSet(CommandType.Text, sqlstatement);
            return ds.Tables[0];
        }
    }

    public enum OrderDirection
    {
        ASC,
        DESC
    }
}
